package com.wisdytech.linkdcs.tool.action;

import com.github.pagehelper.PageInfo;
import com.wisdytech.common.bean.Filter;
import com.wisdytech.common.bean.StandardTableResult;
import com.wisdytech.common.handler.ResourceMatchingService;
import com.wisdytech.linkdcs.tool.model.ToolReplaceRecord;
import com.wisdytech.linkdcs.tool.service.IToolReplaceRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhanghailin
 * @since 2018-06-08
 */
@Controller
@RequestMapping("/tool/replaceRecord")
public class ToolReplaceRecordAction {

    @Resource
    private IToolReplaceRecordService toolReplaceRecordService;
    @Autowired
    @Qualifier("resourceMatchingService")
    private ResourceMatchingService resourceMatchingService;
    /**
     *
     * <p>Description: 工装更换记录查询</p>
     * @param model model
     * @return String
     */
    @RequestMapping("/index")
    public String toolInfoIndex(Model model, HttpServletRequest httpRequest){
        this.resourceMatchingService.getResourceName(httpRequest,model);
        return "tool/toolReplaceRecord";
    }

    @RequestMapping(value = "/getToolReplaceRecordByFilter/get.mvc")
    @ResponseBody
    public StandardTableResult<ToolReplaceRecord> getToolReplacePlanByFilter(String equipCode, String equipName, String toolCode, String toolName, String replaceDateStart, String replaceDateEnd, Filter filter) {
        PageInfo<ToolReplaceRecord> page = toolReplaceRecordService.getToolReplaceRecordByFilter(equipCode, equipName,toolCode,toolName,replaceDateStart,replaceDateEnd,filter);
        return new StandardTableResult<>(page.getTotal(),page.getList());
    }
}
